#encoding:gbk
__author__ = 'administrator'
import os

import sys
import MySQLdb
reload(sys)
sys.setdefaultencoding('gbk')
f=open('d:/line_code_cfg.ini','a')
f2=open('d:/line_name_cfg.ini','a')
conn = MySQLdb.connect(host = "192.168.2.133", user ="mars",passwd = "mars123",db="", port=3306, charset="utf8")
cur = conn.cursor()
conn.select_db('test')
sql1="select * from tmp4"
cur.execute(sql1)
result = cur.fetchall()
for r in result:
    #print r[0],r[1],r[2]
    code1=r[1]+'='+r[2]+'\n'
    #f.write()
    print code1
    name1=r[0]+'='+r[1]+'\n'
    print name1
    f.write(code1)
    f2.write(name1)
f.close()
f2.close()